<template>
  <div class="searchWrapper">
    <div class="searchWrapper-title">
      <p></p>
      <p>查询</p>
    </div>
    <div class="searchWrapper-main">
      <div>
        <a-form layout="inline" :form="form" @submit="handleSubmit">
          <a-form-item label="手机号">
            <a-input
              placeholder="请按照手机号搜索"
              style="width: 200px;"
              v-decorator="[
                'mobile',
                {
                  rules: rule.phone
                }
              ]"
            />
          </a-form-item>
          <a-form-item>
            <a-button type="primary" html-type="submit">搜索</a-button>
          </a-form-item>
          <a-form-item>
            <a-button type="primary" @click="handleReset">重置</a-button>
          </a-form-item>
        </a-form>
        <div>
          <slot name="searchRight"> </slot>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import validate from "@/tool/validateFunction";
export default {
  name: "index",
  data() {
    return {
      form: this.$form.createForm(this),
      rule: {
        phone: [{ validator: validate.validatePhoneNumber }]
      }
    };
  },
  methods: {
    handleSubmit(e) {
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          if (values.mobile) {
            this.$commonJs.goPage("inquire", { mobile: values.mobile });
          }
        }
      });
    },
    handleReset() {
      this.form.resetFields();
    }
  }
};
</script>

<style scoped>
.searchWrapper-title {
  width: 100%;
  padding: 12px 20px 28px 12px;
  display: flex;
  align-items: center;
  color: #323232;
  font-size: 24px;
  border-bottom: 1px solid #eeeeee;
}
.searchWrapper-title > p:first-child {
  width: 5px;
  height: 20px;
  background-color: #42a5fe;
  border-radius: 2px;
  margin-right: 12px;
}
.searchWrapper-main {
  padding: 30px 36px;
  border-bottom: 1px solid #eeeeee;
}
.searchWrapper-main > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8f8f8;
  padding: 10px 31px;
}
</style>
